package cc.javaee.bbs.dao.activity;

import cc.javaee.bbs.dao.BaseDao;
import cc.javaee.bbs.model.activity.KbrActivityCustomer;
import cc.javaee.bbs.params.DbResultMap;
import cc.javaee.bbs.params.WebParams;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ActivityCustomerDao extends BaseDao {
	String ns="kbr_activity_customer.";
	public int insert(KbrActivityCustomer kbrActivityCustomer) {
		return this.getSqlSession().insert(ns+"insert", kbrActivityCustomer);
	}
	
	public List<KbrActivityCustomer> find(KbrActivityCustomer kbrActivityCustomer) {
		List<KbrActivityCustomer> list=this.getSqlSession().selectList(ns+"find", kbrActivityCustomer);
		if(list!=null&&list.size()>0){
		}
		return list;
	}
	
	public String findCustIdStr(WebParams params) {
		String userIdStr="";
		List<DbResultMap> list=this.getSqlSession().selectList(ns+"findDb", params);
		if(list!=null&&list.size()>0){
			for (DbResultMap db  : list) {
				userIdStr+=db.get("custId");
			}
		}
		return userIdStr;
	}
	
	public String findArchivalNumberStr(WebParams params) {
		String archivalNumberStr="";
		List<DbResultMap> list=this.getSqlSession().selectList(ns+"findDb", params);
		if(list!=null&&list.size()>0){
			for (DbResultMap db  : list) {
				archivalNumberStr+=db.get("archivalNumber");
			}
		}
		return archivalNumberStr;
	}
	
	public Integer findCustCount(WebParams params) {
		Integer count=0;
		List<DbResultMap> list=this.getSqlSession().selectList(ns+"findDb", params);
		if(list!=null&&list.size()>0){
			count=list.size();
		}
		return count;
	}

	/**
	 * 根据活动id查询活动用户
	 * @param actId
	 * @return
	 */
	public List<KbrActivityCustomer> findActivityCustomerByActid(int actId) {
		List<KbrActivityCustomer> list=this.getSqlSession().selectList(ns+"findActivityCustomerByActid", actId);
		return list;
	}
	
}